package com.javen.springbootneo4j.controller;

import com.javen.springbootneo4j.entity.node.Person;
import com.javen.springbootneo4j.service.PersonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description: com.javen.springbootneo4j.controller
 * @Author: tujw@netinnet.cn
 * @Date: 2024/2/28 14:16
 */
@RestController
@RequestMapping("/person")
public class PersonController {

    @Autowired
    private PersonService personService;

    @PostMapping("/save")
    public void savePerson(Person person) {
        personService.savePerson(person);
    }

    @GetMapping("/getPerson")
    public Person findPerson(Person person) {
        return personService.getPerson(person);
    }

    @PostMapping("/updateById")
    public void updateById(Long id) {
        personService.updateById(id);
    }

    @PostMapping("/deleteById")
    public void deleteById(Long id) {
        personService.deleteById(id);
    }

    @PostMapping("/assignPersonToCity")
    public Person assignPersonToCity(String personName, String cityName) {
        return personService.nativePersonToCity(personName, cityName);
    }

    @PostMapping("/nativePersonToCity")
    public Person nativePersonToCity(String personName, String cityName) {
        return personService.nativePersonToCity(personName, cityName);
    }

}
